package pt.isel.lercm.projectmanager.spring.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pt.isel.lercm.projectmanager.spring.dao.CategoriaTemplateDAO;
import pt.isel.lercm.projectmanager.spring.model.CategoriaTemplate;

@Service("CategoriaTemplateService")
@Transactional(readOnly = true)
public class CategoriaTemplateService implements ICategoriaTemplateService{
	
	@Autowired
	CategoriaTemplateDAO categoriaTemplateDao;

	public CategoriaTemplateDAO getCategoriaTemplateDao() {
		return categoriaTemplateDao;
	}

	public void setCategoriaTemplateDao(CategoriaTemplateDAO categoriaTemplateDao) {
		this.categoriaTemplateDao = categoriaTemplateDao;
	}

	@Transactional(readOnly = false)
	@Override
	public void add(CategoriaTemplate cat){
		getCategoriaTemplateDao().addObject(cat);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void update(CategoriaTemplate cat){
		getCategoriaTemplateDao().updateObject(cat);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void delete(CategoriaTemplate cat){
		getCategoriaTemplateDao().deleteObject(cat);
	}
	
	@Override
	public CategoriaTemplate getById(int id){
		return getCategoriaTemplateDao().getByid(id);
	}
	
	@Override
	public List<CategoriaTemplate> getAll(){
		return getCategoriaTemplateDao().getAll();
	}
}
